home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / Compiler.java < prev    next >
Text File  |  1998-09-22  |  4KB  |  112 lines

  1. /*
  2.  * @(#)Compiler.java    1.5 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.lang;
  16.  
  17. /**
  18.  * The <code>Compiler</code> class is provided to support 
  19.  * Java-to-native-code compilers and related services. By design, the 
  20.  * <code>Compiler</code> class does nothing; it serves as a 
  21.  * placeholder for a JIT compiler implementation. 
  22.  * <p>
  23.  * When the Java Virtual Machine first starts, it determines if the 
  24.  * system property <code>java.compiler</code> exists. (System 
  25.  * properties are accessible through <code>getProperty</code>  and , 
  26.  * a method defined by the <code>System</code> class.) If so, it is 
  27.  * assumed to be the name of a library (with a platform-dependent 
  28.  * exact location and type); the <code>loadLibrary</code> method in 
  29.  * class <code>System</code> is called to load that library. If this 
  30.  * loading succeeds, the function named 
  31.  * <code>java_lang_Compiler_start()</code> in that library is called. 
  32.  * <p>
  33.  * If no compiler is available, these methods do nothing. 
  34.  *
  35.  * @author  Frank Yellin
  36.  * @version 1.5, 07/01/98
  37.  * @see     java.lang.System#getProperty(java.lang.String)
  38.  * @see     java.lang.System#getProperty(java.lang.String, java.lang.String)
  39.  * @see     java.lang.System#loadLibrary(java.lang.String)
  40.  * @since   JDK1.0
  41.  */
  42. public final class Compiler  {
  43.     private Compiler() {}        // don't make instances
  44.     
  45.     private static native void initialize();
  46.  
  47.     static { 
  48.     String library = null;
  49.     try { 
  50.         library = System.getProperty("java.compiler");
  51.         if ((library != null) && (!library.equals("")) && 
  52.         /* to enable turning off the jit using an env var
  53.            on win32, it is not possible to set an env var
  54.            to an empty string on win32. */
  55.         (!library.equals("NONE"))) { 
  56.         System.loadLibrary(library);
  57.         initialize();
  58.         }
  59.     } catch (UnsatisfiedLinkError e) {
  60.         System.err.println("Warning: JIT compiler \"" + library +
  61.                    "\" not found. Will use interpreter.");
  62.     }
  63.     }
  64.  
  65.     /**
  66.      * Compiles the specified class. 
  67.      *
  68.      * @param   clazz   a class.
  69.      * @return  <code>true</code> if the compilation succeeded;
  70.      *          <code>false</code> if the compilation failed or no compiler
  71.      *          is available.
  72.      * @since   JDK1.0
  73.      */
  74.     public static native boolean compileClass(Class clazz);
  75.  
  76.     /**
  77.      * Compiles all classes whose name matches the specified string. 
  78.      *
  79.      * @param   string   the name of the classes to compile.
  80.      * @return  <code>true</code> if the compilation succeeded;
  81.      *          <code>false</code> if the compilation failed or no compiler
  82.      *          is available.
  83.      * @since   JDK1.0
  84.      */
  85.     public static native boolean compileClasses(String string);
  86.  
  87.     /**
  88.      * Examines the argument type and its fields and perform some documented
  89.      * operation. No specific operations are required. 
  90.      *
  91.      * @param   any   an argument.
  92.      * @return  a compiler-specific value, or <code>null</code> if no compiler
  93.      *          is available.
  94.      * @since   JDK1.0
  95.      */
  96.     public static native Object command(Object any);
  97.  
  98.     /**
  99.      * Cause the Compiler to resume operation. 
  100.      *
  101.      * @since   JDK1.0
  102.      */
  103.     public static native void enable();
  104.  
  105.     /**
  106.      * Cause the Compiler to cease operation. 
  107.      *
  108.      * @since   JDK1.0
  109.      */
  110.     public static native void disable();
  111. }
  112.